import request from '@/utils/request'
export function fetchList(depotId,params) {
  return request({
    url:'/home/promotion/list/'+depotId,
    method:'get',
    params:params
  })
}

export function createPromotion(params) {
  return request({
    url:'/home/promotion/create',
    method:'post',
    data:params
  })
}
export function delPromotion(id) {
    return request({
      url:'/home/promotion/del/'+id,
      method:'get',
    })
  }

export function updatePromotion(data) {
  return request({
    url:'/home/promotion/update',
    method:'post',
    data:data
  })
}

export function getPromotionDetail(pid) {
  return request({
    url:'/home/promotion/detail/info/'+pid,
    method:'get',
  })
}
export function getPromotionDetailList(pid) {
  return request({
    url:'/home/promotion/detail/list/'+pid,
    method:'get',
  })
}
export function createPromotionDetail(params) {
  return request({
    url:'/home/promotion/detail/upsert',
    method:'post',
    data:params
  })
}
export function updatePromotionDetail(params) {
  return request({
    url:'/home/promotion/detail/update',
    method:'post',
    data:params
  })
}
export function delPromotionDetail(id) {
  return request({
    url:'/home/promotion/detail/del/'+id,
    method:'get',
  })
}

//promotion详情，获取已绑定的商品
export function getbindProductInDetail(pdid) {
  return request({
    // url:'/home/promotion/detail/product/bind/'+pid+'/'+pdid,
    url:'/home/promotion/detail/product/'+pdid,//{pdid}
    method:'post',
    // data:arr
  })
}

//promotion详情，绑定商品
export function bindingProducts(arr){
  return request({
    url:'/home/promotion/detail/product/upsert',
    method:'post',
    data:arr
  })
}

//删除已绑定的商品
export function delBindedProducts(pdid,productIds){
  return request({
    url:"/home/promotion/detail/product/del/"+pdid,//{pdid}
    method:"post",
    data:productIds
  })
}